import apiClient from './client';

/**
 * 获取学习时间记录
 * @param params 查询参数
 * @returns 学习时间记录列表
 */
export const getStudyTimeRecords = async (params?: { date?: string }): Promise<{
  code: number;
  message: string;
  data: any[];
  total: number;
}> => {
  return apiClient.get('/api/study/v1/records', {
    params
  });
};

/**
 * 获取学习统计信息
 * @param params 查询参数
 * @returns 学习统计数据
 */
export const getStudyStatistics = async (params?: { date?: string }): Promise<{
  code: number;
  message: string;
  data: {
    total_duration: number;
    avg_duration: number;
    total_progress: number;
    subject_stats: Array<{
      subject_id: number;
      subject_name: string;
      duration: number;
      count: number;
    }>;
  };
}> => {
  return apiClient.get('/api/study/v1/statistics', {
    params
  });
};